import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:sph_shipper/FandCar/DesignatedDriverView.dart';
import 'package:sph_shipper/FandCar/EmptyCarList.dart';
import 'package:sph_shipper/FandCar/MyFamiliarCar.dart';

import '../AppConfig/Config.dart';
import '../AppConfig/RouteAct.dart';
import '../Message/MessageCenter.dart';
import '../SendGoods/AddGoodsFirst.dart';
import '../l10n/messages.dart';
import 'AddFamiliarCars.dart';

class FindCarMain extends StatefulWidget {
  const FindCarMain({super.key});

  @override
  State<FindCarMain> createState() => _FindCarMainState();
}

class _FindCarMainState extends State<FindCarMain> {
  int listType =1;
  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    var messages = AppLocalizations.of(context)!;
    return Scaffold(
      backgroundColor: MyColors.backgreyColor,
      appBar: AppBar(
        automaticallyImplyLeading: false,
        title:  Container(
          height: 25.h,
          width: 190.w,

          decoration: BoxDecoration(
              border: Border.all(
                color: MyColors.themeColor,
                width: 1.0.w,
              ),
              color: Colors.white,
              borderRadius: BorderRadius.all(Radius.circular(30))),
          child:Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              GestureDetector(
                child: Container(
                  width: 60.w,
                  height: 25.h,
                  decoration: BoxDecoration(
                      color: listType==1? MyColors.themeColor:Colors.white,
                      borderRadius: BorderRadius.all(Radius.circular(30))),
                  child: Center(
                    child: Text("空车车源",style: TextStyle(fontSize: 13.sp,color:listType==1? Colors.white:Colors.black,fontWeight: listType==1?FontWeight.w600:FontWeight.w300),),
                  ),

                ),
                onTap: (){
                  setState(() {
                    listType=1;

                  });
                },
              ),
              GestureDetector(
                child: Container(
                  width: 60.w,
                  height: 25.h,
                  decoration: BoxDecoration(
                      color: listType==2? MyColors.themeColor:Colors.white,
                      borderRadius: BorderRadius.all(Radius.circular(30))),
                  child: Center(
                    child: Text("我的熟车",style: TextStyle(fontSize: 13.sp,color:listType==2? Colors.white:Colors.black,fontWeight: listType==2?FontWeight.w600:FontWeight.w300),),
                  ),

                ),
                onTap: (){
                  setState(() {
                    listType=2;
                  });


                },
              ),
              GestureDetector(

                child: Container(
                  width:60.w ,
                  height: 30.h,
                  decoration: BoxDecoration(
                      color: listType==3? MyColors.themeColor:Colors.white,
                      borderRadius: BorderRadius.all(Radius.circular(30))),
                  child: Center(
                    child: Text("指派司机",style: TextStyle(fontSize: 13.sp,color:listType==3? Colors.white:Colors.black,fontWeight: listType==3?FontWeight.w600:FontWeight.w300),),
                  ),

                ),
                onTap: (){
                  setState(() {
                    listType=3;
                  });


                },
              ),
            ],
          ),
        ),

        centerTitle: true,
        backgroundColor: Colors.white,
        actions: [
          GestureDetector(
            child: Text("消息  "),
            onTap: (){
              Navigator.push( context, FadeRoute(page:MessageCenter()));
            },
          ),
          // Badge(label: Text("1"),),
        ],
      ),
      body:  listType==1? EmptyCarList()
      :listType==2?MyFamiliarCar():DesignatedDriverView(goodsMap: {}, findType: 1,),
        // floatingActionButton: listType ==2?Container(
        //   margin: EdgeInsets.only(right: 10.w,bottom: 60.h),
        //   width: 86.0,
        //   height: 40.0,
        //   decoration: BoxDecoration(
        //     gradient: LinearGradient(
        //       begin: Alignment.topCenter,
        //       end: Alignment.bottomCenter,
        //       colors: [MyColors.themeColor, Color.fromRGBO(239,160,82,1)], // 设置渐变颜色
        //     ),
        //     borderRadius: BorderRadius.circular(30.0), // 设置圆角
        //   ),
        //   child: FloatingActionButton(
        //     onPressed: () {
        //       // 在这里处理悬浮按钮被点击时的操作
        //       Navigator.push(context,
        //           MaterialPageRoute(builder: (context) {
        //             return const AddFamiliarCars(
        //
        //             );
        //           }));
        //     },
        //     elevation: 0,
        //     backgroundColor: Colors.transparent,
        //     shape: RoundedRectangleBorder(
        //       borderRadius: BorderRadius.circular(30.0), // 设置圆角
        //     ),
        //     child: Text(
        //       '添加熟车',
        //       style: TextStyle(color: Colors.white,fontSize: 14.sp),
        //     ),
        //   ),

        // ):SizedBox(width: 0,),
    );
  }
}
